﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Control.Bus;

namespace Control.Dal
{
    class DalImportBill
    {
        internal static int Insert(Control.Bus.BusImportBill busImportBill)
        {
            ImportBill Bill = new ImportBill()
            {
                IDStaff = busImportBill.Staff.ID,
                Date = busImportBill.Date
            };
            DalCommon.Database.ImportBills.InsertOnSubmit(Bill);
            DalCommon.Database.SubmitChanges();
            return Bill.ID;
        }



      

        internal static List<Control.Bus.BusImportBill> GetByStaff(Control.Bus.BusStaff staff)
        {
            var bills = from b in DalCommon.Database.ImportBills
                        where b.IDStaff == staff.ID
                        select new BusImportBill()
                        {
                            ID = b.ID,
                            Date = (DateTime)b.Date,
                            Staff = staff
                        };
            return bills.ToList<BusImportBill>();
        }


    }
}
